//
// Created by 陈奕锟 on 2022/11/20.
//

#ifndef AUTOMATICTELLER_RECEIVER_HPP
#define AUTOMATICTELLER_RECEIVER_HPP

#endif //AUTOMATICTELLER_RECEIVER_HPP
#pragma once

#include "message.hpp"
#include "sender.hpp"
#include "dispatcher.hpp"

namespace messaging
{
    class receiver
    {
    private:
        queue q;    // * receiver 实例完全拥有消息队列

    public:
        explicit operator sender()
        {
            return sender(&q);
            // * receiver对象允许隐式转换为sender对象，receiver拥有的队列可以被sender引用
        }

        dispatcher wait()   // * 在队列上等待的行为会创建一个dispatcher对象
        {
            return dispatcher(&q);
        }
    };
}